package hcn.protocol.brandnew.zhenliao.jiancha;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateAdapter;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.brandnew.BaseRequest;
import lombok.Data;
import org.atag.sysrouter.annotation.DictionaryMapping;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;


/**
 * 检查申请信息新增-请求消息 - ODS_03070008
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "MsgBody")
@XmlAccessorType(XmlAccessType.FIELD)
public class PostApplyFormALLRequest extends BaseRequest {

    /**
     * 患者基本信息
     */
    @XmlElement(name = "Patient")
    private Patient patient;
    /**
     * 就诊摘要
     */
    @XmlElement(name = "Visit")
    private Visit visit;
    /**
     * 检查申请单
     */
    @XmlElement(name = "ExmRequest")
    private ExmRequest exmRequest;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {

        /**
         * 区域内患者唯一标识
         */
        @XmlElement(name = "MPI")
        private String mpi;
        /**
         * 业务系统患者档案ID
         */
        @XmlElement(name = "SourcePatientId")
        private String sourcePatientId;
        /**
         * 业务系统患者档案类型
         */
        @XmlElement(name = "SourcePatientIdType")
        private String sourcePatientIdType;
        /**
         * 建档机构代码
         */
        @XmlElement(name = "AuthorOrganization")
        private String authorOrganization;
        /**
         * 身份证件号码
         */
        @XmlElement(name = "IdCard")
        private String idCard;
        /**
         * 身份证件类别代码
         */
        @XmlElement(name = "IdCardCode")
        @DictionaryMapping(id = "CV02_01_101")
        private String idCardCode;
        /**
         * 患者姓名
         */
        @XmlElement(name = "Name")
        private String name;
        /**
         * 性别代码
         */
        @XmlElement(name = "Sex")
        private String sex;
        /**
         * 出生日期
         */
        @XmlElement(name = "BirthDate")
        @XmlJavaTypeAdapter(DateAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
        private Date birthDate;
        /**
         * 电话号码
         */
        @XmlElement(name = "PatientPhone")
        private String patientPhone;
        /**
         * 医保卡号
         */
        @XmlElement(name = "HealthInsuranceCardId")
        private String healthInsuranceCardId;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Visit {

        /**
         * 就诊流水号
         */
        @XmlElement(name = "VisitId")
        private String visitId;
        /**
         * 就诊机构代码/开单机构代码
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;
        /**
         * 患者类型代码
         */
        @XmlElement(name = "PatientType")
        private String patientType;
        /**
         * 就诊卡号
         */
        @XmlElement(name = "MedicalCardId")
        private String medicalCardId;
        /**
         * 就诊卡类别代码
         */
        @XmlElement(name = "MedicalCardType")
        private String medicalCardType;
        /**
         * 门（急）诊号
         */
        @XmlElement(name = "ClinicId")
        private String clinicId;
        /**
         * 住院号
         */
        @XmlElement(name = "HospizationId")
        private String hospizationId;
        /**
         * 就诊日期时间
         */
        @XmlElement(name = "VisitDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date visitDateTime;
        /**
         * 就诊次数
         */
        @XmlElement(name = "VisitTimes")
        private Short visitTimes;
        /**
         * 域ID
         */
        @XmlElement(name = "DomainID")
        private String domainID;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Parts {

        /**
         * 检查部位代码
         */
        @XmlElement(name = "PartsCode")
        private String partsCode;
        /**
         * 检查部位名称
         */
        @XmlElement(name = "PartsName")
        private String partsName;
        /**
         * 检查部位描述
         */
        @XmlElement(name = "PartsDesc")
        private String partsDesc;
        /**
         * 检查部位组号
         */
        @XmlElement(name = "PartsGroupNo")
        private String partsGroupNo;
        /**
         * 检查方法名称
         */
        @XmlElement(name = "ExamMethod")
        private String examMethod;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Item {

        /**
         * 检查项目代码
         */
        @XmlElement(name = "ItemCode")
        private String itemCode;
        /**
         * 检查项目名称
         */
        @XmlElement(name = "ItemName")
        private String itemName;
        /**
         * 检查项目全称
         */
        @XmlElement(name = "ExamPartsText")
        private String examPartsText;
        /**
         * 检查方法代码
         */
        @XmlElement(name = "ExamMethodCode")
        private String examMethodCode;
        /**
         * 检查方法名称
         */
        @XmlElement(name = "ExamMethod")
        private String examMethod;
        /**
         * 检查项目状态代码
         */
        @XmlElement(name = "ItemStatus")
        private String itemStatus;
        /**
         * 项目费用
         */
        @XmlElement(name = "ItemCost")
        private String itemCost;
        /**
         * 计费标志
         */
        @XmlElement(name = "FeeStatus")
        private Boolean feeStatus;
        /**
         * (门诊)发票号码
         */
        @XmlElement(name = "InvoiceNo")
        private String invoiceNo;
        /**
         * 医师医嘱流水号
         */
        @XmlElement(name = "OrderId")
        private String orderId;
        /**
         * 预约标志
         */
        @XmlElement(name = "IsAppointment")
        private Boolean isAppointment;
        /**
         * 预约时间
         */
        @XmlElement(name = "AppointsDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date appointsDateTime;
        /**
         * 预约执行机构
         */
        @XmlElement(name = "AppointsOrganization")
        private String appointsOrganization;
        /**
         * 预约执行科室
         */
        @XmlElement(name = "AppointsDept")
        private String appointsDept;
        /**
         * 预约执行科室名称
         */
        @XmlElement(name = "AppointsDeptName")
        private String appointsDeptName;
        /**
         * 预约顺序号
         */
        @XmlElement(name = "AppointsNo")
        private String appointsNo;
        /**
         * 预约记录流水号
         */
        @XmlElement(name = "AppointsId")
        private String appointsId;
        /**
         * 检查类别代码
         */
        @XmlElement(name = "ExamTypeCode")
        private String examTypeCode;
        /**
         * 检查类别名称
         */
        @XmlElement(name = "ExamTypeName")
        private String examTypeName;
        /**
         * 主要检查部位代码
         */
        @XmlElement(name = "MainPartsCode")
        private String mainPartsCode;
        /**
         * 主要检查部位名称
         */
        @XmlElement(name = "MainPartsName")
        private String mainPartsName;
        /**
         * 检查小项列表
         */
        @XmlElementWrapper(name = "PartsList")
        @XmlElement(name = "Parts")
        private List<Parts> partsList;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Diagnose {

        /**
         * 诊断类别代码
         */
        @XmlElement(name = "DiagnoseTypeCode")
        private String diagnoseTypeCode;
        /**
         * 诊断类别名称
         */
        @XmlElement(name = "DiagnoseTypeName")
        private String diagnoseTypeName;
        /**
         * 诊断日期时间
         */
        @XmlElement(name = "DiagnoseDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date diagnoseDateTime;
        /**
         * 疾病诊断编码
         */
        @XmlElement(name = "DiagnoseCode")
        private String diagnoseCode;
        /**
         * 疾病诊断名称
         */
        @XmlElement(name = "DiagnoseName")
        private String diagnoseName;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class ExmRequest {

        /**
         * 检查申请单编号
         */
        @XmlElement(name = "RequestId")
        private String requestId;
        /**
         * 婴儿判别
         */
        @XmlElement(name = "IsNeonatus")
        private Boolean isNeonatus;
        /**
         * 年龄（岁）
         */
        @XmlElement(name = "Age")
        private Short age;
        /**
         * 年龄（月）
         */
        @XmlElement(name = "MonthAge")
        private String monthAge;
        /**
         * 地址
         */
        @XmlElement(name = "Address")
        private String address;
        /**
         * 病房号
         */
        @XmlElement(name = "SickRoomId")
        private String sickRoomId;
        /**
         * 科室代码
         */
        @XmlElement(name = "Dept")
        private String dept;
        /**
         * 患者科室名称
         */
        @XmlElement(name = "DeptName")
        private String deptName;
        /**
         * 病区代码
         */
        @XmlElement(name = "WardArea")
        private String wardArea;
        /**
         * 患者病区名称
         */
        @XmlElement(name = "WardAreaName")
        private String wardAreaName;
        /**
         * 病床号
         */
        @XmlElement(name = "SickbedId")
        private String sickbedId;
        /**
         * 主诉
         */
        @XmlElement(name = "ChiefComplaint")
        private String chiefComplaint;
        /**
         * 简要病史
         */
        @XmlElement(name = "DiseasesHistory")
        private String diseasesHistory;
        /**
         * 症状与体征
         */
        @XmlElement(name = "PhysicalSign")
        private String physicalSign;
        /**
         * 相关检验结果
         */
        @XmlElement(name = "RefLabResult")
        private String refLabResult;
        /**
         * 检查目的
         */
        @XmlElement(name = "ExamPurpose")
        private String examPurpose;
        /**
         * 紧急标志
         */
        @XmlElement(name = "IsEmergency")
        private Boolean isEmergency;
        /**
         * 申请时间
         */
        @XmlElement(name = "RequestDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date requestDateTime;
        /**
         * 申请医师代码
         */
        @XmlElement(name = "RequestDoctor")
        private String requestDoctor;
        /**
         * 申请医师姓名
         */
        @XmlElement(name = "RequestDoctorName")
        private String requestDoctorName;
        /**
         * 申请医师签名
         */
        @XmlElement(name = "RequestDoctorSign")
        private String requestDoctorSign;
        /**
         * 申请审核医师代码
         */
        @XmlElement(name = "AuditDoctor")
        private String auditDoctor;
        /**
         * 申请审核医师姓名
         */
        @XmlElement(name = "AuditDoctorName")
        private String auditDoctorName;
        /**
         * 申请科室代码
         */
        @XmlElement(name = "RequestDept")
        private String requestDept;
        /**
         * 申请科室名称
         */
        @XmlElement(name = "RequestDeptName")
        private String requestDeptName;
        /**
         * 检查组合项目名称
         */
        @XmlElement(name = "ExamText")
        private String examText;
        /**
         * 申请执行地点
         */
        @XmlElement(name = "ExamExecutePlace")
        private String examExecutePlace;
        /**
         * 申请执行机构
         */
        @XmlElement(name = "ExamExecuteOrg")
        private String examExecuteOrg;
        /**
         * 申请执行科室
         */
        @XmlElement(name = "ExamExecuteDept")
        private String examExecuteDept;
        /**
         * 申请执行科室名称
         */
        @XmlElement(name = "ExamExecuteDeptName")
        private String examExecuteDeptName;
        /**
         * 检查费用
         */
        @XmlElement(name = "ExamCost")
        private String examCost;
        /**
         * 申请单有效开始时间
         */
        @XmlElement(name = "RequestStartDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date requestStartDateTime;
        /**
         * 申请单有效结束时间
         */
        @XmlElement(name = "RequestEndDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date requestEndDateTime;
        /**
         * 优先级别代码
         */
        @XmlElement(name = "PriorityCode")
        private String priorityCode;
        /**
         * 优先级别名称
         */
        @XmlElement(name = "PriorityName")
        private String priorityName;
        /**
         * 审核时间
         */
        @XmlElement(name = "AuditDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date auditDateTime;
        /**
         * 执行时间
         */
        @XmlElement(name = "ExecuteDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date executeDateTime;
        /**
         * 注意事项
         */
        @XmlElement(name = "AnesthesiaAttentionProblem")
        private String anesthesiaAttentionProblem;
        /**
         * 备注
         */
        @XmlElement(name = "RemarkInfo")
        private String remarkInfo;
        /**
         * 临床诊断
         */
        @XmlElement(name = "ClinicalDiagnose")
        private String clinicalDiagnose;
        /**
         * 检查大项列表
         */
        @XmlElementWrapper(name = "ItemList")
        @XmlElement(name = "Item")
        private List<Item> itemList;
        /**
         * 诊断列表
         */
        @XmlElementWrapper(name = "DiagnoseList")
        @XmlElement(name = "Diagnose")
        private List<Diagnose> diagnoseList;
    }

}
